package com.xbongbong.saas.enums;


import lombok.Getter;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;


/**
 * 系统中各业务对应的数值，以后其他的业务数值相关的枚举都将是此枚举的子集（历史数据将会有一次大的处理，将我们系统底层的枚举统一起来）
 *
 * @author feng.zheng
 * 创建时间：2020/5/15 10:47
 * @version 1.0
 * @since 1.0
 */
@Getter
public enum BusinessTypeToServiceEnum {
    REFUND(Collections.singletonList(202)),
    RETURNED_PURCHASE(Collections.singletonList(1201)),
    INSTOCK(Arrays.asList(1404,1405,1406,1407,1408)),
    OUTSTOCK(Arrays.asList(1504,1505,1506,1507,1508)),
    PRODUCT(Collections.singletonList(2401)),
    INVENTORY(Collections.singletonList(1701)),
    TRANSFER(Collections.singletonList(1601)),
    ASSEMBLE(Collections.singletonList(1301)),
    UNKNOWN(Collections.emptyList());
    ;


    /**
     * 枚举值 --
     */
    private final List<Integer> typeList;

    BusinessTypeToServiceEnum(List<Integer> typeList) {
        this.typeList = typeList;
    }

    /**
     * 通过枚举 businessType 获得枚举
     *
     * @param businessType 枚举别名
     *
     * @return XbbRefTypeEnum
     */
    public static BusinessTypeToServiceEnum getByBusinessType(Integer businessType) {
        for (BusinessTypeToServiceEnum cacheCode : values()) {
            if (cacheCode.getTypeList().contains(businessType)) {
                return cacheCode;
            }
        }
        return UNKNOWN;
    }
}
